function Swiper(el) {
    //this 指向swiper1、swiper2

    //这里保存大家都需要使用的数据
    this.el = document.querySelector(el)  //指向实例化对象swiper1、swiper2最大的盒模型
    this.page = this.el.querySelectorAll('ul li')
    this.t = null
    this.num = 1
    //套娃入口，启动插件
    this.init()
}

Swiper.prototype.init = function() {
    // 功能
    //1、自动切换轮播图
    this.autoplay()   // this指向swiper1、swiper2
    //2、分页器移入 - 停止定时器
    this.pageOver()
    //3、分页器移出 - 启动定时器
    this.pageOut()
}

Swiper.prototype.autoplay = function() { // this指向swiper1、swiper2
    // let num = 1
    this.t = setInterval(() => { //this指向父函数中的this
        this.num++
        if (this.num > 6) this.num = 1
        //改变图片地址
        this.el.querySelector('img').src = `./imgs/img${this.num}.jpg`
        //分页器同步
        // let ulObjs = this.el.querySelectorAll('ul li')
        // this.el.querySelector('ul li.active').className = ''
        // ulObjs[num-1].className = 'active'
        this.tbPage(this.num)
    },1000)
}

Swiper.prototype.tbPage = function(num){
    // 分页器同步
    // let ulObjs = this.el.querySelectorAll('ul li')
    this.el.querySelector('ul li.active').className = ''
    this.page[num-1].className = 'active'
}

Swiper.prototype.pageOver = function(){  //this指向swiper1、swiper2
    this.page.forEach((item,i) => {  //item是一个个分页器，即li标签对象
        //绑定移入事件
        // item.onmouseover = function(){  // this 指向事件源
        item.onmouseover =() => {     // this 指向swiper1、swiper2
            //清除定时器
            clearInterval(this.t)
            //重置num ？？
            this.num = i+1
            //换成当前图片
            this.el.querySelector('img').src = `./imgs/img${i+1}.jpg`
            //同步分页器
            this.tbPage(this.num)
        }
    })
}

Swiper.prototype.pageOut = function() {
    this.page.forEach(item => {  //item是一个个分页器，即li标签对象
        //绑定移出事件
        // item.onmouseout = function(){ //this指向事件源
        item.onmouseout = () => {  //this指向swiper1、swiper2
        //重启定时器  
        this.autoplay()      
        }
    })
}